#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <iostream>

struct Guess {
    std::string name;
    int val;
    
    Guess(std::string const & name_, int const & val_) : name(name_), val(val_) {}
};

int main() {

    int N;
    std::cin >> N;
    
    std::vector<Guess> guesses;
    guesses.reserve(N);

    for (int i = 0; i < N; ++i) {
        std::string name;
        int val;
        
        std::cin >> name >> val;
        guesses.emplace_back(name, val);
    }

    auto half_avg = std::accumulate(guesses.begin(), guesses.end(), 0, [](auto sum, auto const & item){
        return sum + item.val;
    }) / (2 * N);
    
    auto winner = std::min_element(guesses.begin(), guesses.end(), [half_avg](auto const & a, auto const & b){
        return std::abs(a.val - half_avg) < std::abs(b.val - half_avg);
    });

    std::cout << half_avg << " " << winner->name;
}
